package com.org.flow.system.service.impl;

import com.org.flow.system.mapper.BusinessExceptionLogMapper;
import com.org.flow.system.model.bo.order.GovernmentBO;
import com.org.flow.system.service.TestService;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

@Service
@Slf4j
@RequiredArgsConstructor
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class TestServiceImpl implements TestService {

    @Resource
    private FlowExecutor flowExecutor;

    /**
     * 环节信息记录
     */
    private final BusinessExceptionLogMapper mapper;


    @Override
    public Object test2(GovernmentBO bo) {
        LiteflowResponse response = flowExecutor.execute2Resp("chain2", bo, GovernmentBO.class);
        if (response.isSuccess()) {
            return "执行成功!";
        }
        return response.getMessage();
    }

    @Override
    public Object test3(Map<String, String> map3) {
        return mapper.selectByInParameter(map3);
    }

}
